"""通用数据模型"""

from datetime import datetime
from typing import Optional

from pydantic import BaseModel, Field


class BaseResponse(BaseModel):
    """基础响应模型"""

    success: bool = Field(..., description="请求是否成功")
    msg: str = Field(..., description="响应消息")
    code: str = Field(..., description="响应代码")
    timestamp: str = Field(default_factory=lambda: datetime.now().strftime("%Y-%m-%d %H:%M:%S"), description="响应时间")


class PaginationParams(BaseModel):
    """分页参数模型"""

    page: int = Field(default=1, ge=1, description="页码，从1开始")
    page_size: int = Field(default=10, ge=1, le=100, description="每页条数，最大100")


class PaginationInfo(BaseModel):
    """分页信息模型"""

    total: int = Field(..., description="总记录数")
    page: int = Field(..., description="当前页码")
    page_size: int = Field(..., description="每页条数")
    total_pages: int = Field(..., description="总页数")
    has_next: bool = Field(..., description="是否有下一页")
    has_prev: bool = Field(..., description="是否有上一页")


class HealthCheckResponse(BaseModel):
    """健康检查响应模型"""

    status: str = Field(..., description="服务状态")
    version: str = Field(..., description="应用版本")
    timestamp: str = Field(..., description="检查时间")
    environment: str = Field(..., description="运行环境")
    dependencies: Optional[dict] = Field(None, description="依赖服务状态")